package cn.dceast.former.controller;

import cn.dceast.common.data.RtnData;
import cn.dceast.common.utils.DataUtil;
import cn.dceast.former.model.EyeModelComment;
import cn.dceast.former.model.EyeModelData;
import cn.dceast.former.model.EyeModelIndustry;
import cn.dceast.former.service.EyeIndustryService;
import cn.dceast.former.service.EyeModelCommentService;
import cn.dceast.former.service.EyeModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by fanbo on 2017-07-18.
 * 模型行业
 */
@Controller
@RequestMapping("/eyeCommentController")
@Api(tags = {"eyeCommentController"})
public class EyeModelCommentController {
    public static final Logger logger = LoggerFactory.getLogger(EyeModelCommentController.class);

    @Autowired
    private EyeModelCommentService eyeModelCommentService;

    /**
     * 添加评论

     * @return
     */
    @ApiOperation(value = "添加评论", notes = "添加评论")
    @RequestMapping(value = "/addComment.do", method = RequestMethod.GET)
    @ResponseBody
    public RtnData addComment(EyeModelComment comment,HttpSession session){
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("content", comment.getContent());
        params.put("score", comment.getScore());
        params.put("modelId", comment.getModelId());
        params.put("userid", session.getAttribute("userid").toString());
        int successOr = eyeModelCommentService.AddModelEvaluate(params);
        if(successOr>0){
            return RtnData.ok("添加成功");
        }else{
            return RtnData.fail("添加失败");
        }
    }
}
